using System;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;

namespace WebApiFrame.Filters
{
    
    public class SimpleExceptionFilterAttribute : Attribute, IExceptionFilter
    {
        private readonly ILogger<SimpleExceptionFilterAttribute> logger;
        public SimpleExceptionFilterAttribute(ILoggerFactory loggerFactory)
        {
         logger=loggerFactory.CreateLogger<SimpleExceptionFilterAttribute>();
        }
        public void OnException(ExceptionContext context)
        {
          logger.LogError(" OnException:"+context.Exception.Message);
          context.ExceptionHandled=true;
        }
    }
}